package Exercise;


import java.util.Scanner;

/**
 * Description：
 * Author: zhangc
 * Date：2017/8/8 22:05
 */
public class MultiMax {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int studentNumber = scanner.nextInt();
        int[] student = new int[ studentNumber ];
        for (int i = 0; i < student.length; i++) {
            student[ i ] = scanner.nextInt();
        }
        int selectK = scanner.nextInt();
        int difLess = scanner.nextInt(); // 位置差不超过difLess
        multiMax(student, selectK, difLess);
    }

    // f[i][k] 表示最后一个数以a[i]结尾的最大积
    // f[i,k] = Max {f[j, k -1] * a[i]} (i - j <= d);
    //负数比较麻烦
    //-4 5 6 -8 2 4
    // k为3的时候，输出结果不对
    //所以一直没有Ac
    public static long multiMax(int[] student, int selectK, int difLess) {
        long[][] maxMul = new long[ student.length ][ selectK + 1 ];
        long[][] minMul = new long[ student.length ][ selectK + 1 ];
        long maxResult = student[ 0 ];
        for (int i = 0; i < maxMul.length; i++) {
            maxMul[ i ][ 0 ] = 1; // 初始化为1
            minMul[ i ][ 0 ] = 1; // 初始化为1
        }
        for (int i = 0; i < maxMul.length; i++) {
            maxMul[ i ][ 1 ] = student[ i ];
            minMul[ i ][ 1 ] = student[ i ];
            if (student[ i ] > maxResult) {
                maxResult = student[ i ];
            }
        }
        for (int k = 2; k < maxMul[ 0 ].length; k++) {
            for (int i = 0; i < maxMul.length; i++) {
                long tempMax, tempMin, curMax = Integer.MIN_VALUE, curMin = Integer.MAX_VALUE;
                //必须要有k个数
                if (i < k - 1) {
                    maxMul[ i ][ k ] = 1;
                    minMul[ i ][ k ] = 1;
                } else {
                    // 找出最大情况的j
                    for (int j = k - 2; j < maxMul.length; j++) {
                        if (j >= i - difLess && j < i) {
                            tempMax = maxMul[ j ][ k - 1 ] * student[ i ];
                            tempMin = minMul[ j ][ k - 1 ] * student[ i ];
                            curMax = Math.max(curMax, Math.max(tempMax, tempMin));
                            curMin = Math.min(curMin, Math.min(tempMax, tempMin));
                        }
                        maxMul[ i ][ k ] = curMax;
                        minMul[ i ][ k ] = curMin;
                        maxResult = Math.max(maxResult, curMax);
                    }
                }
            }
        }
        return maxResult;
    }

    //    public static void main(String[] args) {
//        int[] array = {9, 4, 6, 8, 3, -8, 7, -9};
//        long l = multiMax(array, 2, 2);
//        System.out.println(l);
//    }
}
